package io.renren.modules.achievements.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.achievements.entity.ResearchPatentEntity;
import io.renren.modules.achievements.service.ResearchPatentService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 科研专利表
 *
 * @author sc
 * @email 2170147754@qq.com
 * @date 2021-12-28 10:27:56
 */
@RestController
@RequestMapping("achievements/researchpatent")
public class ResearchPatentController {
    @Autowired
    private ResearchPatentService researchPatentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("achievements:researchpatent:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = researchPatentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("achievements:researchpatent:info")
    public R info(@PathVariable("id") Long id){
		ResearchPatentEntity researchPatent = researchPatentService.getById(id);

        return R.ok().put("researchPatent", researchPatent);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("achievements:researchpatent:save")
    public R save(@RequestBody ResearchPatentEntity researchPatent){
		researchPatentService.save(researchPatent);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("achievements:researchpatent:update")
    public R update(@RequestBody ResearchPatentEntity researchPatent){
		researchPatentService.updateById(researchPatent);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("achievements:researchpatent:delete")
    public R delete(@RequestBody Long[] ids){
		researchPatentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
